package com.example.myapplication.control;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.SimpleAdapter;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

import com.example.myapplication.DataBaseActivity;
import com.example.myapplication.R;
import com.example.myapplication.SQLiteHelperActivity;

public class ScrollViewActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_down;
    private Button btn_up;
    private ScrollView scrollView;
    private TextView txt_show;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scroll_view);
        bindViews();
    }

    private void bindViews() {
        btn_down = (Button) findViewById(R.id.scroll_down);
        btn_up = (Button) findViewById(R.id.scroll_top);
        scrollView = (ScrollView) findViewById(R.id.scrollView);
        txt_show = (TextView) findViewById(R.id.txt_show);
        btn_down.setOnClickListener(this);
        btn_up.setOnClickListener(this);

        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= 100; i++) {
            sb.append("呵呵 * " + i + "\n");
        }
        txt_show.setText(sb.toString());
        //SimpleAdapter myAdapter = new SimpleAdapter(getApplicationContext(), listitem, R.layout.list_item, new String[]{"touxiang", "name", "says"}, new int[]{R.id.imgtou, R.id.name, R.id.says});

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.scroll_down:
                scrollView.fullScroll(ScrollView.FOCUS_DOWN);
                Intent intent = new Intent();
                intent.setClass(this, SQLiteHelperActivity.class);
                startActivity(intent);
                break;
            case R.id.scroll_top:
                scrollView.fullScroll(ScrollView.FOCUS_UP);
                break;
        }
    }
}